//
//  AddressManagerTableViewCell.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/25.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "AddressManagerTableViewCell.h"

@interface AddressManagerTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *iphone;
@property (weak, nonatomic) IBOutlet UILabel *address1;
@property (weak, nonatomic) IBOutlet UILabel *address2;
- (IBAction)selectClick:(id)sender;


@end

@implementation AddressManagerTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype) AddressManagerWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"cell";
    AddressManagerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"AddressManagerTableViewCell" owner:nil options:nil] lastObject];
    }
    return cell;
}

- (void)setDic:(NSDictionary *)dic
{
    _dic = dic;
    self.name.text = dic[@"name"];
    self.iphone.text = dic[@"iphone"];
    self.address1.text = dic[@"address1"];
    self.address2.text = dic[@"address2"];
    [self.selectBtn setBackgroundImage:[UIImage imageNamed:@"goodNotSelected.png"] forState:UIControlStateNormal];
    self.selectBtn.hidden = YES;
}

- (IBAction)selectClick:(id)sender {
    if (self.b == 0) {
        [self.selectBtn setBackgroundImage:[UIImage imageNamed:@"goodSelected.png"] forState:UIControlStateNormal];
        [self.delegate addThing:self.a];
        self.b = 1;
    }else
    {
        [self.selectBtn setBackgroundImage:[UIImage imageNamed:@"goodNotSelected.png"] forState:UIControlStateNormal];
        [self.delegate deleteThing:self.a];
        self.b = 0;
    }
}
@end
